package com.goodving.guli.bt.profile.scale;

import android.bluetooth.BluetoothGatt;
import android.support.v4.internal.view.SupportMenu;
import android.util.Log;
import android.view.accessibility.AccessibilityNodeInfo;

import com.goodving.guli.bt.model.PersonInfo;
import com.goodving.guli.bt.utils.ProfileUtils;
import com.goodving.guli.utility.gulihardware.Constant;
import com.goodving.guli.view.C3657a;
import com.goodving.guli.view.C4220a;

import java.lang.reflect.Field;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;

/**
 * Created by Administrator on 2015/11/25 0025.
 */
public class GattUtils  { //  C3892y
    public static final UUID f19564a;
    public static final UUID f19565b;
    public static UUID f19566c = null;
    public static UUID f19567d = null;
    private static final String TAG = "GattUtils";
    private static final String f19569f = "0000%4s-0000-1000-8000-00805f9b34fb";
    private static final String f19570g;
    private static final long f19571h = 4096;
    private static final long f19572i = -9223371485494954757L;
    private static final int[] f19573j;
    private static final byte BLE_FLAGS = (byte) 1;
    private static final byte BLE_INCOMPLETE_16BITS_UUID = (byte) 2;
    private static final byte BLE_COMPLETE_16BITS_UUID = (byte) 3;
    private static final byte BLE_INCOMPLETE_128BITS_UUID = (byte) 6;
    private static final byte BLE_COMPLETE_128BITS_UUID = (byte) 7;
    private static final byte BLE_SHORTENED_LOCAL_NAME = (byte) 8;
    private static final byte BLE_COMPLETE_LOCAL_NAME = (byte) 9;
    private static final byte BLE_TX_POWER_LEVEL = (byte) 10;
    private static final byte BLE_16BITS_SER_SOL_UUID = (byte) 20;
    private static final byte BLE_128BITS_SER_SOL_UUID = (byte) 21;
    private static final byte BLE_SERVICE_DATA = (byte) 22;
    private static final byte BLE_MANUFACTURE_SPEC_DATA = (byte) -1;
    private static Field mField;

    static {
        f19570g = String.format(f19569f, new Object[]{"...."});
        f19564a = GattUtils.m25322a("2902");
        f19565b = GattUtils.m25322a("2901");
        f19566c = new UUID(303230942, 1523193452336828707L);
        f19567d = new UUID(-1152921504534413312L, -5764607523034234880L);
        f19573j = new int[]{0, 49345, 49537, C4220a.by, 49921, 960, 640, 49729, 50689, 1728, 1920, 51009, 1280, 50625, 50305, 1088, 52225, 3264, 3456, 52545, 3840, 53185, 52865, 3648, 2560, 51905, 52097, 2880, 51457, 2496, 2176, 51265, 55297, 6336, 6528, 55617, 6912, 56257, 55937, 6720, 7680, 57025, 57217, C4220a.bS, 56577, 7616, 7296, 56385, 5120, 54465, 54657, 5440, 55041, 6080, 5760, 54849, 53761, 4800, 4992, 54081, 4352, 53697, 53377, 4160, 61441, 12480, 12672, 61761, 13056, 62401, 62081, 12864, 13824, 63169, 63361, 14144, 62721, 13760, 13440, 62529, 15360, 64705, 64897, 15680, C3867z.f19487h, 16320, 16000, 65089, 64001, 15040, 15232, 64321, 14592, 63937, 63617, 14400, 10240, 59585, 59777, 10560, 60161, 11200, 10880, 59969, 60929, 11968, 12160, 61249, 11520, 60865, 60545, 11328, 58369, 9408, 9600, 58689, 9984, 59329, 59009, 9792, 8704, 58049, 58241, 9024, 57601, 8640, 8320, 57409, 40961, 24768, 24960, 41281, 25344, 41921, 41601, 25152, 26112, 42689, 42881, 26432, 42241, 26048, 25728, 42049, 27648, 44225, 44417, 27968, 44801, 28608, 28288, 44609, 43521, 27328, 27520, 43841, 26880, 43457, 43137, 26688, 30720, 47297, 47489, 31040, 47873, 31680, 31360, 47681, 48641, 32448, 32640, 48961, Constant.df, 48577, 48257, 31808, 46081, 29888, 30080, 46401, 30464, 47041, 46721, 30272, 29184, 45761, 45953, 29504, 45313, 29120, 28800, 45121, 20480, 37057, 37249, 20800, 37633, 21440, 21120, 37441, 38401, 22208, 22400, 38721, 21760, 38337, 38017, 21568, 39937, 23744, 23936, 40257, 24320, 40897, 40577, 24128, 23040, 39617, 39809, 23360, 39169, 22976, 22656, 38977, 34817, 18624, 18816, 35137, 19200, 35777, 35457, 19008, 19968, 36545, 36737, 20288, 36097, 19904, 19584, 35905, 17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448};
        mField = null;
    }

    public static int m25318a(int i, byte[] bArr, int i2, int i3) {
        while (i2 < i3) {
            int i4 = (((i >>> 8) | (i << 8)) & SupportMenu.USER_MASK) ^ (bArr[i2] & HeartRateInfo.HR_EMPTY_VALUE);
            i4 ^= (i4 & HeartRateInfo.HR_EMPTY_VALUE) >> 4;
            i4 ^= (i4 << 12) & SupportMenu.USER_MASK;
            i = i4 ^ (((i4 & HeartRateInfo.HR_EMPTY_VALUE) << 5) & SupportMenu.USER_MASK);
            i2++;
        }
        return i;
    }

    public static int printClientIf(BluetoothGatt bluetoothGatt) { // m25319a
        if (mField == null) {
            try {
                mField = BluetoothGatt.class.getDeclaredField("mClientIf");
                mField.setAccessible(true);
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            }
        }
        try {
            return mField.getInt(bluetoothGatt);
        } catch (IllegalAccessException e2) {
            e2.printStackTrace();
            return -1;
        } catch (IllegalArgumentException e3) {
            e3.printStackTrace();
            return -1;
        }
    }

    public static int m25320a(byte[] bArr, int i) {
        return GattUtils.m25339c(bArr, i, 4);
    }

    public static UUID m25321a(int i) {
        return new UUID(((((long) i) & 4294967295L) << 32) | f19571h, f19572i);
    }

    public static UUID m25322a(String str) {
        return UUID.fromString(String.format(f19569f, new Object[]{str}));
    }

    public static UUID m25323a(UUID uuid, int i) {
        return GattUtils.m25324a(uuid, (short) i);
    }

    public static UUID m25324a(UUID uuid, short s) {
        return new UUID((uuid.getMostSignificantBits() & -281470681743361L) | ((((long) s) & 65535) << 32), uuid.getLeastSignificantBits());
    }

    public static UUID m25325a(short s) {
        return GattUtils.m25321a(SupportMenu.USER_MASK & s);
    }

    public static UUID m25326a(byte[] bArr) {
        switch (bArr.length) {
            case C4220a.f20888k /*2*/:
                return GattUtils.m25322a(String.format("%02x%02x", new Object[]{Byte.valueOf(bArr[0]), Byte.valueOf(bArr[1])}));
            case C4220a.bp /*16*/:
                StringBuilder stringBuilder = new StringBuilder(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
                stringBuilder.append(String.format("%02x%02x%02x%02x", new Object[]{Byte.valueOf(bArr[0]), Byte.valueOf(bArr[1]), Byte.valueOf(bArr[2]), Byte.valueOf(bArr[3])}));
                stringBuilder.append(String.format("-%02x%02x-%02x%02x", new Object[]{Byte.valueOf(bArr[4]), Byte.valueOf(bArr[5]), Byte.valueOf(bArr[6]), Byte.valueOf(bArr[7])}));
                stringBuilder.append(String.format("-%02x%02x-%02x%02x", new Object[]{Byte.valueOf(bArr[8]), Byte.valueOf(bArr[9]), Byte.valueOf(bArr[10]), Byte.valueOf(bArr[11])}));
                stringBuilder.append(String.format("%02x%02x%02x%02x", new Object[]{Byte.valueOf(bArr[12]), Byte.valueOf(bArr[13]), Byte.valueOf(bArr[14]), Byte.valueOf(bArr[15])}));
                return GattUtils.m25336b(stringBuilder.toString());
            default:
                return null;
        }
    }

    public static short m25327a(UUID uuid) {
        return (short) GattUtils.m25332b(uuid);
    }

    public static void m25328a(byte[] bArr, int i, int i2) {
        int i3 = i + 1;
        bArr[i] = (byte) ((i2 >> 0) & HeartRateInfo.HR_EMPTY_VALUE);
        int i4 = i3 + 1;
        bArr[i3] = (byte) ((i2 >> 8) & HeartRateInfo.HR_EMPTY_VALUE);
        i3 = i4 + 1;
        bArr[i4] = (byte) ((i2 >> 16) & HeartRateInfo.HR_EMPTY_VALUE);
        i4 = i3 + 1;
        bArr[i3] = (byte) ((i2 >> 24) & HeartRateInfo.HR_EMPTY_VALUE);
    }

    public static void m25329a(byte[] bArr, int i, short s) {
        int i2 = i + 1;
        bArr[i] = (byte) ((s >> 0) & HeartRateInfo.HR_EMPTY_VALUE);
        int i3 = i2 + 1;
        bArr[i2] = (byte) ((s >> 8) & HeartRateInfo.HR_EMPTY_VALUE);
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static boolean m25330a(byte[] r14, java.util.UUID[] r15) {
        /*
        r13 = 6;
        r12 = 3;
        r11 = 2;
        r1 = 1;
        r2 = 0;
        r0 = r14.length;
        r3 = 62;
        if (r0 != r3) goto L_0x0015;
    L_0x000a:
        r0 = r1;
    L_0x000b:
        cn.com.smartdevices.bracelet.GuliLog.ASSERTION_TRUE(r0);
        r0 = r2;
    L_0x000f:
        r3 = 62;
        if (r0 < r3) goto L_0x0017;
    L_0x0013:
        r1 = r2;
    L_0x0014:
        return r1;
    L_0x0015:
        r0 = r2;
        goto L_0x000b;
    L_0x0017:
        r3 = r0 + 1;
        r6 = r14[r0];
        if (r6 == 0) goto L_0x0013;
    L_0x001d:
        r0 = r6 + r3;
        r4 = 62;
        if (r0 > r4) goto L_0x0013;
    L_0x0023:
        r0 = r3 + 1;
        r3 = r14[r3];
        if (r3 == r12) goto L_0x002b;
    L_0x0029:
        if (r3 != r11) goto L_0x006e;
    L_0x002b:
        r3 = r2;
    L_0x002c:
        r4 = r6 + -1;
        if (r3 >= r4) goto L_0x000f;
    L_0x0030:
        r5 = new byte[r11];
        r7 = r0 + 1;
        r0 = r14[r0];
        r5[r2] = r0;
        r4 = r7 + 1;
        r0 = r14[r7];
        r5[r1] = r0;
        r0 = "%02x%02x";
        r7 = new java.lang.Object[r11];
        r8 = r5[r1];
        r8 = java.lang.Byte.valueOf(r8);
        r7[r2] = r8;
        r5 = r5[r2];
        r5 = java.lang.Byte.valueOf(r5);
        r7[r1] = r5;
        r5 = java.lang.String.format(r0, r7);
        r7 = r15.length;
        r0 = r2;
    L_0x0058:
        if (r0 >= r7) goto L_0x0069;
    L_0x005a:
        r8 = r15[r0];
        r8 = com.goodving.hm.health.bt.p094c.GattUtils.m25341c(r8);
        r8 = r8.equals(r5);
        if (r8 != 0) goto L_0x0014;
    L_0x0066:
        r0 = r0 + 1;
        goto L_0x0058;
    L_0x0069:
        r0 = r3 + 2;
        r3 = r0;
        r0 = r4;
        goto L_0x002c;
    L_0x006e:
        r4 = 7;
        if (r3 == r4) goto L_0x0073;
    L_0x0071:
        if (r3 != r13) goto L_0x0173;
    L_0x0073:
        r5 = r2;
    L_0x0074:
        r3 = r6 + -1;
        if (r5 >= r3) goto L_0x000f;
    L_0x0078:
        r3 = 16;
        r7 = new byte[r3];
        r3 = r0;
        r0 = r2;
    L_0x007e:
        r4 = 16;
        if (r0 >= r4) goto L_0x008c;
    L_0x0082:
        r4 = r3 + 1;
        r3 = r14[r3];
        r7[r0] = r3;
        r0 = r0 + 1;
        r3 = r4;
        goto L_0x007e;
    L_0x008c:
        r0 = "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x";
        r4 = 16;
        r4 = new java.lang.Object[r4];
        r8 = 15;
        r8 = r7[r8];
        r8 = java.lang.Byte.valueOf(r8);
        r4[r2] = r8;
        r8 = 14;
        r8 = r7[r8];
        r8 = java.lang.Byte.valueOf(r8);
        r4[r1] = r8;
        r8 = 13;
        r8 = r7[r8];
        r8 = java.lang.Byte.valueOf(r8);
        r4[r11] = r8;
        r8 = 12;
        r8 = r7[r8];
        r8 = java.lang.Byte.valueOf(r8);
        r4[r12] = r8;
        r8 = 4;
        r9 = 11;
        r9 = r7[r9];
        r9 = java.lang.Byte.valueOf(r9);
        r4[r8] = r9;
        r8 = 5;
        r9 = 10;
        r9 = r7[r9];
        r9 = java.lang.Byte.valueOf(r9);
        r4[r8] = r9;
        r8 = 9;
        r8 = r7[r8];
        r8 = java.lang.Byte.valueOf(r8);
        r4[r13] = r8;
        r8 = 7;
        r9 = 8;
        r9 = r7[r9];
        r9 = java.lang.Byte.valueOf(r9);
        r4[r8] = r9;
        r8 = 8;
        r9 = 7;
        r9 = r7[r9];
        r9 = java.lang.Byte.valueOf(r9);
        r4[r8] = r9;
        r8 = 9;
        r9 = r7[r13];
        r9 = java.lang.Byte.valueOf(r9);
        r4[r8] = r9;
        r8 = 10;
        r9 = 5;
        r9 = r7[r9];
        r9 = java.lang.Byte.valueOf(r9);
        r4[r8] = r9;
        r8 = 11;
        r9 = 4;
        r9 = r7[r9];
        r9 = java.lang.Byte.valueOf(r9);
        r4[r8] = r9;
        r8 = 12;
        r9 = r7[r12];
        r9 = java.lang.Byte.valueOf(r9);
        r4[r8] = r9;
        r8 = 13;
        r9 = r7[r11];
        r9 = java.lang.Byte.valueOf(r9);
        r4[r8] = r9;
        r8 = 14;
        r9 = r7[r1];
        r9 = java.lang.Byte.valueOf(r9);
        r4[r8] = r9;
        r8 = 15;
        r7 = r7[r2];
        r7 = java.lang.Byte.valueOf(r7);
        r4[r8] = r7;
        r4 = java.lang.String.format(r0, r4);
        r7 = r15.length;
        r0 = r2;
    L_0x013e:
        if (r0 >= r7) goto L_0x016d;
    L_0x0140:
        r8 = r15[r0];
        r9 = new java.lang.StringBuilder;
        r9.<init>();
        r10 = r8.toString();
        r9 = r9.append(r10);
        r10 = "==";
        r9 = r9.append(r10);
        r9 = r9.append(r4);
        r9 = r9.toString();
        cn.com.smartdevices.bracelet.GuliLog.m12350a(r9);
        r8 = com.goodving.hm.health.bt.p094c.GattUtils.m25341c(r8);
        r8 = r8.equals(r4);
        if (r8 != 0) goto L_0x0014;
    L_0x016a:
        r0 = r0 + 1;
        goto L_0x013e;
    L_0x016d:
        r0 = r5 + 16;
        r5 = r0;
        r0 = r3;
        goto L_0x0074;
    L_0x0173:
        r3 = r6 + -1;
        r0 = r0 + r3;
        goto L_0x000f;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.goodving.hm.health.bt.c.y.a(byte[], java.util.UUID[]):boolean");
    }

    public static byte[] m25331a(byte[] bArr, byte[] bArr2) {
        try {
            Cipher instance = Cipher.getInstance("AES/ECB/NoPadding");
            instance.init(1, new SecretKeySpec(bArr, "AES"));
            return instance.doFinal(bArr2);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        } catch (NoSuchPaddingException e2) {
            e2.printStackTrace();
            return null;
        } catch (InvalidKeyException e3) {
            e3.printStackTrace();
            return null;
        } catch (IllegalBlockSizeException e4) {
            e4.printStackTrace();
            return null;
        } catch (BadPaddingException e5) {
            e5.printStackTrace();
            return null;
        }
    }

    public static int m25332b(UUID uuid) {
        long mostSignificantBits = uuid.getMostSignificantBits();
        return (uuid.getLeastSignificantBits() == f19572i && (4294967295L & mostSignificantBits) == f19571h) ? (int) (mostSignificantBits >> 32) : 0;
    }

    public static int m25333b(byte[] bArr, int i, int i2) {
        if (i >= bArr.length || i > i2) {
            return 0;
        }
        int i3 = SupportMenu.USER_MASK;
        while (i < i2) {
            i3 = (((i3 << 8) | (i3 >>> 8)) & SupportMenu.USER_MASK) ^ (bArr[i] & HeartRateInfo.HR_EMPTY_VALUE);
            i3 ^= (i3 & HeartRateInfo.HR_EMPTY_VALUE) >> 4;
            i3 ^= (i3 << 12) & SupportMenu.USER_MASK;
            i3 ^= ((i3 & HeartRateInfo.HR_EMPTY_VALUE) << 5) & SupportMenu.USER_MASK;
            i++;
        }
        return i3 & SupportMenu.USER_MASK;
    }

    public static String m25334b(int i) {
        StringBuilder stringBuilder = new StringBuilder();
        if ((i & 1) > 0) {
            stringBuilder.append("BROADCAST ");
        }
        if ((i & AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) > 0) {
            stringBuilder.append("EXTENDED_PROPS ");
        }
        if ((i & 32) > 0) {
            stringBuilder.append("INDICATE ");
        }
        if ((i & 16) > 0) {
            stringBuilder.append("NOTIFY ");
        }
        if ((i & 2) > 0) {
            stringBuilder.append("READ ");
        }
        if ((i & 64) > 0) {
            stringBuilder.append("SIGNED_WRITE ");
        }
        if ((i & 8) > 0) {
            stringBuilder.append("WRITE ");
        }
        if ((i & 4) > 0) {
            stringBuilder.append("WRITE_NO_RESPONSE ");
        }
        return stringBuilder.toString();
    }

    public static String m25335b(byte[] bArr) {
        GuliLog.ASSERT_NOT_NULL((Object) bArr);
        if (bArr == null || bArr.length == 0) {
            return C3657a.f18328f;
        }
        StringBuilder stringBuilder = new StringBuilder();
        int length = bArr.length;
        for (int i = 0; i < length; i++) {
            stringBuilder.append(String.format("%02x ", new Object[]{Byte.valueOf(bArr[i])}));
        }
        return stringBuilder.substring(0, stringBuilder.length() - 1);
    }

    public static UUID m25336b(String str) {
        return UUID.fromString(str);
    }

    public static byte[] m25337b(byte[] bArr, byte[] bArr2) {
        try {
            Cipher instance = Cipher.getInstance("AES/ECB/NoPadding");
            instance.init(2, new SecretKeySpec(bArr, "AES"));
            return instance.doFinal(bArr2);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        } catch (NoSuchPaddingException e2) {
            e2.printStackTrace();
            return null;
        } catch (InvalidKeyException e3) {
            e3.printStackTrace();
            return null;
        } catch (IllegalBlockSizeException e4) {
            e4.printStackTrace();
            return null;
        } catch (BadPaddingException e5) {
            e5.printStackTrace();
            return null;
        }
    }

    public static int m25338c(byte[] bArr) {
        int i = SupportMenu.USER_MASK;
        for (byte b : bArr) {
            i = (((i << 8) | (i >>> 8)) & SupportMenu.USER_MASK) ^ (b & HeartRateInfo.HR_EMPTY_VALUE);
            i ^= (i & HeartRateInfo.HR_EMPTY_VALUE) >> 4;
            i ^= (i << 12) & SupportMenu.USER_MASK;
            i ^= ((i & HeartRateInfo.HR_EMPTY_VALUE) << 5) & SupportMenu.USER_MASK;
        }
        return i & SupportMenu.USER_MASK;
    }

    public static int m25339c(byte[] bArr, int i, int i2) {
        int i3 = 0;
        int i4 = 0;
        while (i3 < i2) {
            i4 |= (bArr[i + i3] & HeartRateInfo.HR_EMPTY_VALUE) << (i3 * 8);
            i3++;
        }
        return i4;
    }

    public static String m25340c(int i) {
        StringBuilder stringBuilder = new StringBuilder();
        if ((i & 1) > 0) {
            stringBuilder.append("READ ");
        }
        if ((i & 2) > 0) {
            stringBuilder.append("READ_ENCRYPTED ");
        }
        if ((i & 4) > 0) {
            stringBuilder.append("READ_ENCRYPTED_MITM ");
        }
        if ((i & 16) > 0) {
            stringBuilder.append("WRITE ");
        }
        if ((i & 32) > 0) {
            stringBuilder.append("WRITE_ENCRYPTED ");
        }
        if ((i & 64) > 0) {
            stringBuilder.append("WRITE_ENCRYPTED_MITM ");
        }
        if ((i & AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) > 0) {
            stringBuilder.append("WRITE_SIGNED ");
        }
        if ((i & PersonInfo.INCOMING_CALL_DISABLE_BIT) > 0) {
            stringBuilder.append("WRITE_SIGNED_MITM ");
        }
        return stringBuilder.toString();
    }

    public static String m25341c(UUID uuid) {
        String uuid2 = uuid.toString();
        return uuid2.matches(f19570g) ? uuid2.substring(4, 8) : uuid2;
    }

    public static int m25342d(byte[] bArr) {
        int i = 0;
        for (byte b : bArr) {
            i ^= b & HeartRateInfo.HR_EMPTY_VALUE;
            for (int i2 = 0; i2 < 8; i2++) {
                i = (i & 1) != 0 ? ((i >> 1) & HeartRateInfo.HR_EMPTY_VALUE) ^ 140 : (i >> 1) & HeartRateInfo.HR_EMPTY_VALUE;
            }
        }
        return i;
    }

    public static C3907e m25343e(byte[] bArr) {
        GuliLog.ASSERTION_TRUE(bArr.length == 62);
        C3907e c3907e = new C3907e();

        //  TBD DEBUG
        int i10;
        StringBuilder debugStringBuilder = new StringBuilder();

        for (i10 = 0; i10 < bArr.length; i10++)
        {
            debugStringBuilder.append(bArr[i10]);
            debugStringBuilder.append(" ");
        }

        Log.e(TAG, debugStringBuilder.toString());

        int i = 0;
        while (i < 62) {
            int i2 = i + 1;
            byte b = bArr[i];
            if (b != 0 && b + i2 <= 62) {
                int i3 = i2 + 1;
                byte[] bArr2;
                String b2;
                StringBuilder stringBuilder;
                int i4;
                byte[] bArr3;
                switch (bArr[i2]) {
                    // to get the manufacture information
                    case BLE_MANUFACTURE_SPEC_DATA /*-1*/:
                        bArr2 = new byte[(b - 1)];
                        i = i3;
                        i3 = 0;
                        while (i3 < b - 1) {
                            i2 = i + 1;
                            bArr2[i3] = bArr[i];
                            i3++;
                            i = i2;
                        }
                        b2 = GattUtils.m25335b(bArr2);
                        c3907e.manufact = b2;
                        GuliLog.m12350a("    manufact: " + b2);
                        // ge
                        continue;
                        // to get the flag
                    case BLE_FLAGS /*1*/:
                        GuliLog.ASSERTION_TRUE(b == 2);
                        i = i3 + 1;
                        byte tempbyte = bArr[i3];
                        c3907e.flags = tempbyte;
                        GuliLog.m12350a("        flag: " + String.format("%02x", new Object[]{Byte.valueOf(bArr[i3])}));// TBDr1

                        continue; // get this from decompile website instead of JADX
                        // to get the *serv16, the UUID information
                    case BLE_INCOMPLETE_16BITS_UUID /*2*/:
                        stringBuilder = new StringBuilder();
                        i4 = 0;
                        i = i3;
                        while (i4 < b - 1) {
                            bArr3 = new byte[2];
                            i3 = i;
                            i = 0;
                            while (i < 2) {
                                i2 = i3 + 1;
                                bArr3[i] = bArr[i3];
                                i++;
                                i3 = i2;
                            }
                            c3907e.inServ16.add(String.format("%02x%02x", new Object[]{Byte.valueOf(bArr3[1]), Byte.valueOf(bArr3[0])}));
                            stringBuilder.append(GattUtils.m25335b(bArr3));
                            stringBuilder.append("; ");
                            i4 += 2;
                            i = i3;
                        }
                        GuliLog.m12350a("   (*)serv16: " + stringBuilder.toString());
                        continue;
                        // to get the serv16, the UUID information
                    case BLE_COMPLETE_16BITS_UUID /*3*/:
                        stringBuilder = new StringBuilder();
                        i4 = 0;
                        i = i3;
                        while (i4 < b - 1) {
                            bArr3 = new byte[2];
                            i3 = i;
                            i = 0;
                            while (i < 2) {
                                i2 = i3 + 1;
                                bArr3[i] = bArr[i3];
                                i++;
                                i3 = i2;
                            }
                            c3907e.serv16.add(String.format("%02x%02x", new Object[]{Byte.valueOf(bArr3[1]), Byte.valueOf(bArr3[0])}));
                            stringBuilder.append(GattUtils.m25335b(bArr3));
                            stringBuilder.append("; ");
                            i4 += 2;
                            i = i3;
                        }
                        GuliLog.m12350a("      serv16: " + stringBuilder.toString());
                        continue;
                        // to get the serv128, full UUID information
                    case BLE_INCOMPLETE_128BITS_UUID /*6*/:
                        stringBuilder = new StringBuilder();
                        i4 = 0;
                        i = i3;
                        while (i4 < b - 1) {
                            bArr3 = new byte[16];
                            i3 = i;
                            i = 0;
                            while (i < 16) {
                                i2 = i3 + 1;
                                bArr3[i] = bArr[i3];
                                i++;
                                i3 = i2;
                            }
                            c3907e.inServ128.add(String.format("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", new Object[]{Byte.valueOf(bArr3[15]), Byte.valueOf(bArr3[14]), Byte.valueOf(bArr3[13]), Byte.valueOf(bArr3[12]), Byte.valueOf(bArr3[11]), Byte.valueOf(bArr3[10]), Byte.valueOf(bArr3[9]), Byte.valueOf(bArr3[8]), Byte.valueOf(bArr3[7]), Byte.valueOf(bArr3[6]), Byte.valueOf(bArr3[5]), Byte.valueOf(bArr3[4]), Byte.valueOf(bArr3[3]), Byte.valueOf(bArr3[2]), Byte.valueOf(bArr3[1]), Byte.valueOf(bArr3[0])}));
                            stringBuilder.append(GattUtils.m25335b(bArr3));
                            stringBuilder.append("; ");
                            i4 += 16;
                            i = i3;
                        }
                        GuliLog.m12350a("  (*)serv128: " + stringBuilder.toString());
                        continue;
                        // to get the serv128, full UUID information
                    case BLE_COMPLETE_128BITS_UUID /*7*/:
                        stringBuilder = new StringBuilder();
                        i4 = 0;
                        i = i3;
                        while (i4 < b - 1) {
                            bArr3 = new byte[16];
                            i3 = i;
                            i = 0;
                            while (i < 16) {
                                i2 = i3 + 1;
                                bArr3[i] = bArr[i3];
                                i++;
                                i3 = i2;
                            }
                            c3907e.serv128.add(String.format("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", new Object[]{Byte.valueOf(bArr3[15]), Byte.valueOf(bArr3[14]), Byte.valueOf(bArr3[13]), Byte.valueOf(bArr3[12]), Byte.valueOf(bArr3[11]), Byte.valueOf(bArr3[10]), Byte.valueOf(bArr3[9]), Byte.valueOf(bArr3[8]), Byte.valueOf(bArr3[7]), Byte.valueOf(bArr3[6]), Byte.valueOf(bArr3[5]), Byte.valueOf(bArr3[4]), Byte.valueOf(bArr3[3]), Byte.valueOf(bArr3[2]), Byte.valueOf(bArr3[1]), Byte.valueOf(bArr3[0])}));
                            stringBuilder.append(GattUtils.m25335b(bArr3));
                            stringBuilder.append("; ");
                            i4 += 16;
                            i = i3;
                        }
                        GuliLog.m12350a("     serv128: " + stringBuilder.toString());
                        continue;
                        // to get the name
                    case BLE_SHORTENED_LOCAL_NAME /*8*/:
                        bArr2 = new byte[(b - 1)];
                        i = i3;
                        i3 = 0;
                        while (i3 < b - 1) {
                            i2 = i + 1;
                            bArr2[i3] = bArr[i];
                            i3++;
                            i = i2;
                        }
                        b2 = new String(bArr2);
                        c3907e.shortLocalName = b2;
                        GuliLog.m12350a("     (*)name: " + b2);
                        continue;
                        // to get the name
                    case BLE_COMPLETE_LOCAL_NAME /*9*/:
                        bArr2 = new byte[(b - 1)];
                        i = i3;
                        i3 = 0;
                        while (i3 < b - 1) {
                            i2 = i + 1;
                            bArr2[i3] = bArr[i];
                            i3++;
                            i = i2;
                        }
                        b2 = new String(bArr2);
                        c3907e.localName = b2;
                        GuliLog.m12350a("        name: " + b2);
                        continue;
                        // to get the tx level, looks like it is related to the signal strength of bluetooth
                    case BLE_TX_POWER_LEVEL /*10*/:
                        bArr2 = new byte[(b - 1)];
                        i = i3;
                        i3 = 0;
                        while (i3 < b - 1) {
                            i2 = i + 1;
                            bArr2[i3] = bArr[i];
                            i3++;
                            i = i2;
                        }
                        b2 = GattUtils.m25335b(bArr2);
                        c3907e.txLevel = b2;
                        GuliLog.m12350a("    tx level: " + b2);
                        continue;
                        // to get solicit16
                    case BLE_16BITS_SER_SOL_UUID /*20*/:
                        stringBuilder = new StringBuilder();
                        i4 = 0;
                        i = i3;
                        while (i4 < b - 1) {
                            bArr3 = new byte[2];
                            i3 = i;
                            i = 0;
                            while (i < 2) {
                                i2 = i3 + 1;
                                bArr3[i] = bArr[i3];
                                i++;
                                i3 = i2;
                            }
                            stringBuilder.append(GattUtils.m25335b(bArr3));
                            stringBuilder.append("; ");
                            i4 += 2;
                            i = i3;
                        }
                        c3907e.solicit16 = stringBuilder.toString();
                        GuliLog.m12350a("   solicit16: " + stringBuilder.toString());
                        continue;
                        // to get solicit128
                    case BLE_128BITS_SER_SOL_UUID /*21*/:
                        stringBuilder = new StringBuilder();
                        i4 = 0;
                        i = i3;
                        while (i4 < b - 1) {
                            bArr3 = new byte[16];
                            i3 = i;
                            i = 0;
                            while (i < 16) {
                                i2 = i3 + 1;
                                bArr3[i] = bArr[i3];
                                i++;
                                i3 = i2;
                            }
                            stringBuilder.append(GattUtils.m25335b(bArr3));
                            stringBuilder.append("; ");
                            i4 += 16;
                            i = i3;
                        }
                        c3907e.solicit128 = stringBuilder.toString();
                        GuliLog.m12350a("  solicit128: " + stringBuilder.toString());
                        continue;
                        // to get weightinfo
                    case BLE_SERVICE_DATA /*22*/:
                        byte[] obj = new byte[(b - 1)];
                        i = i3;
                        i3 = 0;
                        while (i3 < b - 1) {
                            i2 = i + 1;
                            obj[i3] = bArr[i];
                            i3++;
                            i = i2;
                        }
                        if (obj.length != 12) {
                            c3907e.scaleWeightInfo = ProfileUtils.m25641a(obj, false, false);
                            break;
                        }
                        if (!C3923a.y_.equals(GattUtils.m25322a(String.format("%02X%02X", new Object[]{Byte.valueOf(obj[1]), Byte.valueOf(obj[0])})))) {
                            GuliLog.m12370d(TAG, "UUID is not UUID_SERVICE_WEIGHT_SCALE_SERVICE<181D>!!!");
                            break;
                        }
                        byte[] obj2 = new byte[(obj.length - 2)];
                        System.arraycopy(obj, 2, obj2, 0, obj2.length);
                        c3907e.scaleWeightInfo = ProfileUtils.m25641a(obj2, false, false);
                        continue;
                    default:
                        byte[] bArr4 = new byte[(b - 1)];
                        i = i3;
                        i3 = 0;
                        while (i3 < b - 1) {
                            i2 = i + 1;
                            bArr4[i3] = bArr[i];
                            i3++;
                            i = i2;
                        }
                        c3907e.other = String.format("[0x%02x]", new Object[]{Byte.valueOf(bArr4[i3])}) + ": " + GattUtils.m25335b(bArr4);
                        GuliLog.m12350a("      " + String.format("[0x%02x]", new Object[]{Byte.valueOf(bArr4[i3])}) + ": " + GattUtils.m25335b(bArr4));
                        break;
                }
            }
            return c3907e;
        }
        return c3907e;
    }

    private static int m25344f(byte[] bArr) {
        int i = 0;
        int length = bArr.length;
        int i2 = 0;
        while (i < length) {
            int i3 = i2 >>> 8;
            i2 = f19573j[(i2 ^ bArr[i]) & HeartRateInfo.HR_EMPTY_VALUE] ^ i3;
            i++;
        }
        return i2;
    }
}

